package util

import "yunj/pkg/global"

// 获取ip区域信息
func IpRegion(ip string) (region string, err error) {
	region, err = global.IpSearcher.SearchByStr(ip)
	return
}

// 获取ip区域省份信息
func IpRegionProvince(region string) (province string) {
	province = global.ProvinceRegexp.FindString(region)
	return
}

// 获取ip省份信息
func IpProvince(ip string) (province string, err error) {
	region, err := IpRegion(ip)
	if err != nil || region == "" {
		return
	}
	province = IpRegionProvince(region)
	return
}
